/**
 * 
 */

function convertButton_Click()
{
	var inputText = document.mapleForm.inputTextBox.value;
	var outputText = Convert(inputText, document.mapleForm.outputTextBox.value);
	var https = "https"
	if (document.mapleForm.httpsCheckbox.checked)
		outputText = outputText.replace(/https/g, "http");
	document.mapleForm.outputTextBox.value = outputText;
}

function Convert (convertIText, convertText)
{
	var startLocation;
	var endLocation;
	var outputString;
	outputString = "[url=";
	startLocation = convertIText.indexOf("<a href=\"http");
	if (startLocation <0)
		return;
	startLocation = convertIText.indexOf("http", startLocation);
	endLocation = convertIText.indexOf("\"", startLocation);
	if (endLocation < startLocation)
		return;
	
	outputString += convertIText.substring(startLocation, endLocation);
	outputString += "][img]";
	startLocation = convertIText.indexOf("http", endLocation);
	if (startLocation < endLocation)
		return;
	endLocation = convertIText.indexOf("\"", startLocation);
	if (endLocation < startLocation)
		return;
	outputString += convertIText.substring(startLocation, endLocation);
	outputString += "[/img][/url]";
	return outputString;
}